import Vue from "vue";
import Router from "vue-router";
import Home from "../views/Home";
import Collect from "../views/Collect";
import Contact from "../views/Contact";
import AccountLogin from "../views/Login";
import AccountRegister from "../views/Register";
import AccountSetting from "../views/Setting";
import Project from "../views/Project";
import SerachResult from "../views/Result";
import ProjectDetailInfo from "../views/DetailInfo";
import Forget from "../views/ForgetPwd";
// import personInfo from "../views/personInfo";
Vue.use(Router);

export default new Router({
  mode: "history",

  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition;
    } else {
      if (from.meta.keepAlive) {
        from.meta.savedPosition = document.body.scrollTop
      }
      return { x: 0, y: to.meta.savedPosition || 0 }
    }
    
  },
  base: process.env.BASE_URL,
  routes: [
    //主页
    {
      path: "/",
      name: "home",
      component: Home,
      meta: {
        title: 'home',
        keepAlive: true
      }
    },
    // //分类查询页 
    // {
    //   path: "/Project/:id",
    //   name: "Project",
    //   component: Project
    // },
    //全部分类
    {
      path: "/Project/:projectClass",
      name: "Project",
      component: Project,
      meta: {
        title: 'Project',
        keepAlive: true
      }
    },

    {
      path: "/Project",
      name: "Projectid",
      component: Project
    },

    //产品详情
    {
      path: "/DetailInfo/:projectid",
      name: "ProjectDetailInfo",
      component: ProjectDetailInfo
    },
    //用户登录
    {
      path: "/Login",
      name: "AccountLogin",
      component: AccountLogin
    },
    //用户注册
    {
      path: "/Register",
      name: "AccountRegister",
      component: AccountRegister
    },
    //用户设置
    {
      path: "/Setting",
      name: "AccountSetting",
      component: AccountSetting
    },

    //忘记密码
    {
      path: "/Forget",
      name: "Forget",
      component: Forget
    },
    //搜索结果
    {
      path: "/Result/:keyword",
      name: "SerachResult",
      component: SerachResult,
      // meta: {
      //   title: 'SerachResult',
      //   keepAlive: true
      // }
    },
    //客服中心
    {
      path: "/contact",
      name: "Contact",
      component: Contact
    },
    //收藏管理
    {
      path: "/Collect",
      name: "Collect",
      component: Collect
    },

    //个人中心
    // {
    //   path: "/personInfo",
    //   name: "personInfo",
    //   component: personInfo
    // }
  ]
});
